import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int p1=sc.nextInt();
        int p2=sc.nextInt();
        int p3=sc.nextInt();
        int time=0;
        while (true){
            if (time>100){
                System.out.println("so sad!");
                return;
            }
            time++;
            p1++;
            p2++;
            p3++;
            if (p1%10==3){
                if (p2%10==6){
                    if (p3%10==9){
                        System.out.println(time);
                        return;
                    }
                }
                if (p2%10==9){
                    if (p3%10==6){
                        System.out.println(time);
                        return;
                    }
                }
            }else if (p1%10==6){
                if (p2%10==3){
                    if (p3%10==9){
                        System.out.println(time);
                        return;
                    }
                }
                if (p2%10==9){
                    if (p3%10==3){
                        System.out.println(time);
                        return;
                    }
                }
            }else if (p1%10==9){
                if (p2%10==3){
                    if (p3%10==6){
                        System.out.println(time);
                        return;
                    }
                }
                if(p2%10==6){
                    if (p3%10==3){
                        System.out.println(time);
                        return;
                    }
                }
            }
        }
    }
}
